package jdbcTest.dao;


import jdbcTest.JdbcUtils;
import jdbcTest.entity.Student;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;

public class StudentDao implements dao<Student> {
	Connection connection = null;
	PreparedStatement preparedStatement = null;

	@Override
	public List<Student> finAll() {
		return null;
	}

	@Override
	public void add(Student student) {
		String sql = "insert into students values (?,?,?)";
		connection = JdbcUtils.getConn();

		try {
			preparedStatement = connection.prepareStatement(sql);
			preparedStatement.setInt(1,student.getId());
			preparedStatement.setNString(2,student.getName());
			preparedStatement.setInt(3,student.getAge());
			preparedStatement.execute();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public void updata(int i, Student student) {

	}

	@Override
	public void delete(int i) {

	}
}
